//
//  SRProgressView.m
//  SportRing
//
//  Created by mykoma on 14-4-6.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "LGProgressView.h"

#define DEFAULT_BACKGROUND_COLOR ([UIColor red:214 green:214 blue:214 alpha:1.0])
#define DEFAULT_PROGRESS_COLOR ([UIColor red:24 green:181 blue:90 alpha:1.0])

@interface LGProgressView ()
{
    UIView * _progressView;
}

@end

@implementation LGProgressView

#pragma mark - SRBaseViewProtocol

-(void)setupViews
{
    self.backgroundColor = DEFAULT_BACKGROUND_COLOR;
    _progressView = [[UIView alloc] init];
    _progressView.backgroundColor = DEFAULT_PROGRESS_COLOR;
    
    [self addSubview:_progressView];
}

-(void)setProgressColor:(UIColor *)progressColor
{
    _progressView.backgroundColor = progressColor;
}

-(void)setProgress:(NSUInteger)progress
{
    if (progress > 100)
    {
        progress = 100;
    }
    
    [self setProgressPercent:progress / 100.0f];
}

#pragma mark - Private

-(void)setProgressPercent:(float)percent
{
    CGFloat width = CGRectGetWidth(self.bounds) * percent;
    _progressView.frame = CGRectMake(0, 0,
                                     width, CGRectGetHeight(self.bounds));
}

@end
